package ynu.sxp.demoapp.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ynu.sxp.demoapp.entity.Food;
import ynu.sxp.demoapp.service.FoodService;
import ynu.sxp.demoapp.common.Result;

import java.util.List;

@RestController
@RequestMapping("/FoodController")
public class FoodController {

    @Autowired
    private FoodService foodService;

    // 根据商家ID获取食品列表
    @GetMapping("/listFoodByBusinessId")
    public Result<List<Food>> listFoodByBusinessId(@RequestParam Integer businessId) {
        List<Food> foods = foodService.getFoodsByBusinessId(businessId);
        return Result.success(foods);
    }

    // 获取所有食品信息
    @GetMapping("/listAllFoods")
    public Result<List<Food>> listAllFoods() {
        List<Food> foods = foodService.getAllFoods();
        return Result.success(foods);
    }
}